/**
 * ----------------------------------------------------------------------------
 * Copyright Jens Konopka
 * 
 * Alle Rechte vorbehalten.
 * Licence: Apache 2.0
 * ----------------------------------------------------------------------------
 *
 * created on 05.03.2012 by jkonopka
 */
package de.sql.toolkit.generator;

import java.io.File;

import de.sql.toolkit.Resource;
import de.sql.toolkit.model.Table;

/**
 * @author jkonopka
 * 
 */
public abstract class AbstractJvModelGenerator extends AbstractGenerator {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2410436841128207734L;

	/**
	 * @param dstPath
	 * @param table
	 */
	public AbstractJvModelGenerator(File dstPath, final Table table) {
		super(table, dstPath);
	}

	/**
	 * @param key
	 * @param isNullable
	 * @return
	 */
	protected final String getFieldType(final String search, final boolean isNullable) {
		final String nullable = (isNullable) ? ".is_nullable" : "";
		final String key = "sql." + getFieldTypeProgrammingLanguageKey() + ".type." + search + nullable;
		final String value = Resource.getProperty(key);
		return value;
	}

	/**
	 * @return
	 */
	protected String getFieldTypeProgrammingLanguageKey() {
		return "java";
	}

	/**
	 * @param column
	 * @return
	 */
	protected String prepareName(String name) {
		name = name.replaceAll(" ", "");
		name = name.replaceAll("_", "");
		// name = name.replaceAll(".", "");
		name = name.toLowerCase();
		return name;
	}

}
